# Default recipe to display help
default:
    @echo "You should create a soft link to this file in repo root dir to use"
    @just --list

# Initialize the ethernet configuration
init:
    bash ${STARRY_CON_SCRIPT}/con/set_en.sh

# Capture console log and sync to remote server
capture_log:
    bash ${STARRY_CON_SCRIPT}/con/capture_log.sh

# Build the project (LOG=debug MODE=debug BACKTRACE=y by default)
build LOG="debug" MODE="debug" BACKTRACE="y":
    @echo "Building project with LOG={{LOG}} MODE={{MODE}} BACKTRACE={{BACKTRACE}}..."
    LOG={{LOG}} MODE={{MODE}} BACKTRACE={{BACKTRACE}} bash ${STARRY_CON_SCRIPT}/con/build.sh

# Build and push to git
build-push LOG="debug" MODE="debug" BACKTRACE="y":
    @echo "Building and pushing with LOG={{LOG}} MODE={{MODE}} BACKTRACE={{BACKTRACE}}..."
    LOG={{LOG}} MODE={{MODE}} BACKTRACE={{BACKTRACE}} bash ${STARRY_CON_SCRIPT}/con/build.sh push
    just capture_log

# Build axplat-opi5p (LOG=info MODE=release APP=rstiny by default)
build-axplat LOG="info" MODE="release" APP="rstiny":
    @echo "Building axplat-opi5p with LOG={{LOG}} MODE={{MODE}} APP={{APP}}..."
    LOG={{LOG}} MODE={{MODE}} APP={{APP}} bash ${STARRY_CON_SCRIPT}/con/build_axplat.sh

# Build axplat-opi5p and push to git
build-axplat-push LOG="info" MODE="release" APP="rstiny":
    @echo "Building axplat-opi5p and pushing with LOG={{LOG}} MODE={{MODE}} APP={{APP}}..."
    LOG={{LOG}} MODE={{MODE}} APP={{APP}} bash ${STARRY_CON_SCRIPT}/con/build_axplat.sh push
    just capture_log

# Prepare boot image then flash it
flash_boot:
    @echo "Flashing boot..."
    bash ${STARRY_CON_SCRIPT}/con/flash_boot.sh

# Flash rootfs
flash_rootfs:
    @echo "Flashing rootfs..."
    bash ${STARRY_CON_SCRIPT}/con/flash_rootfs.sh

# Flash uimage
flash:
    @echo "Flashing rootfs..."
    bash ${STARRY_CON_SCRIPT}/con/flash.sh

# Prepare rootfs
prepare_rootfs:
    @echo "Preparing rootfs..."
    bash ${STARRY_CON_SCRIPT}/con/prepare_rootfs.sh

# Update scripts
update_scripts:
    @echo "Updating scripts..."
    bash ${STARRY_CON_SCRIPT}/con/update_scripts.sh

# Update log
update_log:
    @echo "Updating log..."
    bash ${STARRY_CON_SCRIPT}/con/update_log.sh

# Clean build artifacts
clean:
    @echo "Cleaning build artifacts..."
    # Add your clean commands here

# Run tests
test:
    @echo "Running tests..."
    # Add your test commands here
